using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;

namespace Data_Access_Tier
{
	public class HRM_CANDIDATEData : DatabaseObjectBase
	{
		public HRM_CANDIDATEData()
		{
			Initialize(true);
		}
		public HRM_CANDIDATEData(Boolean newConnection)
		{
			Initialize(newConnection);
		}

		public Int32 HRM_CANDIDATE_Insert(String CandidateCode, String RecruitmentCode, String FirstName, String LastName, String Marriage, Boolean Sex, DateTime Birthday, String BirthPlace, String MainAddress, String ContactAddress, String CellPhone, String HomePhone, String Email, String Photo, String Nationality, String Ethnic, String Religion, String Language, String Informatic, String Professional, String Education, String Job, String IDCard, DateTime IDCardDate, String IDCardPlace, String Health, Double Height, Double Weight, String Experience, DateTime InputFileDate, String Position1, String Position2, Decimal ExpectSalary, Int32 Status, String PersonName, String PersonPhone, String PersonAddress, String PersonJob, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.InsertCommand = new SqlCommand("HRM_CANDIDATE_Insert");
				_dbadapter.InsertCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.InsertCommand.Connection = _dbconn;
				_trans = _dbconn.BeginTransaction();
				_dbadapter.InsertCommand.Transaction = _trans;
				_dbadapter.InsertCommand.Parameters.Clear();
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@RecruitmentCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar, 50));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Marriage", SqlDbType.NVarChar, 50));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@BirthPlace", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@ContactAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@CellPhone", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Photo", SqlDbType.Image));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Nationality", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Ethnic", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Religion", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Language", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Informatic", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Professional", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Education", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Job", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@IDCardDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@IDCardPlace", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Health", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Height", SqlDbType.Float));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Weight", SqlDbType.Float));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Experience", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@InputFileDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Position1", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Position2", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@ExpectSalary", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonJob", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.InsertCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				SqlString RecruitmentCodeSQL = RecruitmentCode;
				_dbadapter.InsertCommand.Parameters["@RecruitmentCode"].Value = RecruitmentCodeSQL;
				SqlString FirstNameSQL = FirstName;
				_dbadapter.InsertCommand.Parameters["@FirstName"].Value = FirstNameSQL;
				SqlString LastNameSQL = LastName;
				_dbadapter.InsertCommand.Parameters["@LastName"].Value = LastNameSQL;
				SqlString MarriageSQL = Marriage;
				_dbadapter.InsertCommand.Parameters["@Marriage"].Value = MarriageSQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.InsertCommand.Parameters["@Sex"].Value = SexSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlString BirthPlaceSQL = BirthPlace;
				_dbadapter.InsertCommand.Parameters["@BirthPlace"].Value = BirthPlaceSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.InsertCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ContactAddressSQL = ContactAddress;
				_dbadapter.InsertCommand.Parameters["@ContactAddress"].Value = ContactAddressSQL;
				SqlString CellPhoneSQL = CellPhone;
				_dbadapter.InsertCommand.Parameters["@CellPhone"].Value = CellPhoneSQL;
				SqlString HomePhoneSQL = HomePhone;
				_dbadapter.InsertCommand.Parameters["@HomePhone"].Value = HomePhoneSQL;
				SqlString EmailSQL = Email;
				_dbadapter.InsertCommand.Parameters["@Email"].Value = EmailSQL;
				SqlBinary PhotoSQL = Convert.FromBase64String(Photo);
				_dbadapter.InsertCommand.Parameters["@Photo"].Value = PhotoSQL;
				SqlString NationalitySQL = Nationality;
				_dbadapter.InsertCommand.Parameters["@Nationality"].Value = NationalitySQL;
				SqlString EthnicSQL = Ethnic;
				_dbadapter.InsertCommand.Parameters["@Ethnic"].Value = EthnicSQL;
				SqlString ReligionSQL = Religion;
				_dbadapter.InsertCommand.Parameters["@Religion"].Value = ReligionSQL;
				SqlString LanguageSQL = Language;
				_dbadapter.InsertCommand.Parameters["@Language"].Value = LanguageSQL;
				SqlString InformaticSQL = Informatic;
				_dbadapter.InsertCommand.Parameters["@Informatic"].Value = InformaticSQL;
				SqlString ProfessionalSQL = Professional;
				_dbadapter.InsertCommand.Parameters["@Professional"].Value = ProfessionalSQL;
				SqlString EducationSQL = Education;
				_dbadapter.InsertCommand.Parameters["@Education"].Value = EducationSQL;
				SqlString JobSQL = Job;
				_dbadapter.InsertCommand.Parameters["@Job"].Value = JobSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.InsertCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlDateTime IDCardDateSQL = SqlDateTime.Null;
				if (IDCardDate > DateTime.MinValue)
				{
					try
					{
						IDCardDateSQL = IDCardDate;
					}
					catch (Exception eIDCardDate)
					{
						String IDCardDateMessage = eIDCardDate.Message;
						IDCardDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@IDCardDate"].Value = IDCardDateSQL;
				SqlString IDCardPlaceSQL = IDCardPlace;
				_dbadapter.InsertCommand.Parameters["@IDCardPlace"].Value = IDCardPlaceSQL;
				SqlString HealthSQL = Health;
				_dbadapter.InsertCommand.Parameters["@Health"].Value = HealthSQL;
				SqlDouble HeightSQL = Height;
				_dbadapter.InsertCommand.Parameters["@Height"].Value = HeightSQL;
				SqlDouble WeightSQL = Weight;
				_dbadapter.InsertCommand.Parameters["@Weight"].Value = WeightSQL;
				SqlString ExperienceSQL = Experience;
				_dbadapter.InsertCommand.Parameters["@Experience"].Value = ExperienceSQL;
				SqlDateTime InputFileDateSQL = SqlDateTime.Null;
				if (InputFileDate > DateTime.MinValue)
				{
					try
					{
						InputFileDateSQL = InputFileDate;
					}
					catch (Exception eInputFileDate)
					{
						String InputFileDateMessage = eInputFileDate.Message;
						InputFileDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@InputFileDate"].Value = InputFileDateSQL;
				SqlString Position1SQL = Position1;
				_dbadapter.InsertCommand.Parameters["@Position1"].Value = Position1SQL;
				SqlString Position2SQL = Position2;
				_dbadapter.InsertCommand.Parameters["@Position2"].Value = Position2SQL;
				SqlMoney ExpectSalarySQL = ExpectSalary;
				_dbadapter.InsertCommand.Parameters["@ExpectSalary"].Value = ExpectSalarySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.InsertCommand.Parameters["@Status"].Value = StatusSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.InsertCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.InsertCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.InsertCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString PersonJobSQL = PersonJob;
				_dbadapter.InsertCommand.Parameters["@PersonJob"].Value = PersonJobSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.InsertCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.InsertCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_CANDIDATE_Insert: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_CANDIDATE_Insert: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.InsertCommand != null)
					_dbadapter.InsertCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_CANDIDATE_Update(String CandidateCode, String RecruitmentCode, String FirstName, String LastName, String Marriage, Boolean Sex, DateTime Birthday, String BirthPlace, String MainAddress, String ContactAddress, String CellPhone, String HomePhone, String Email, String Photo, String Nationality, String Ethnic, String Religion, String Language, String Informatic, String Professional, String Education, String Job, String IDCard, DateTime IDCardDate, String IDCardPlace, String Health, Double Height, Double Weight, String Experience, DateTime InputFileDate, String Position1, String Position2, Decimal ExpectSalary, Int32 Status, String PersonName, String PersonPhone, String PersonAddress, String PersonJob, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_CANDIDATE_Update");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RecruitmentCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar, 50));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Marriage", SqlDbType.NVarChar, 50));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@BirthPlace", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ContactAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@CellPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Photo", SqlDbType.Image));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Nationality", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Ethnic", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Religion", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Language", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Informatic", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Professional", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Education", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Job", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCardDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCardPlace", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Health", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Height", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Weight", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Experience", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InputFileDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Position1", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Position2", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ExpectSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonJob", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.UpdateCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				SqlString RecruitmentCodeSQL = RecruitmentCode;
				_dbadapter.UpdateCommand.Parameters["@RecruitmentCode"].Value = RecruitmentCodeSQL;
				SqlString FirstNameSQL = FirstName;
				_dbadapter.UpdateCommand.Parameters["@FirstName"].Value = FirstNameSQL;
				SqlString LastNameSQL = LastName;
				_dbadapter.UpdateCommand.Parameters["@LastName"].Value = LastNameSQL;
				SqlString MarriageSQL = Marriage;
				_dbadapter.UpdateCommand.Parameters["@Marriage"].Value = MarriageSQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.UpdateCommand.Parameters["@Sex"].Value = SexSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlString BirthPlaceSQL = BirthPlace;
				_dbadapter.UpdateCommand.Parameters["@BirthPlace"].Value = BirthPlaceSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.UpdateCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ContactAddressSQL = ContactAddress;
				_dbadapter.UpdateCommand.Parameters["@ContactAddress"].Value = ContactAddressSQL;
				SqlString CellPhoneSQL = CellPhone;
				_dbadapter.UpdateCommand.Parameters["@CellPhone"].Value = CellPhoneSQL;
				SqlString HomePhoneSQL = HomePhone;
				_dbadapter.UpdateCommand.Parameters["@HomePhone"].Value = HomePhoneSQL;
				SqlString EmailSQL = Email;
				_dbadapter.UpdateCommand.Parameters["@Email"].Value = EmailSQL;
				SqlBinary PhotoSQL = Convert.FromBase64String(Photo);
				_dbadapter.UpdateCommand.Parameters["@Photo"].Value = PhotoSQL;
				SqlString NationalitySQL = Nationality;
				_dbadapter.UpdateCommand.Parameters["@Nationality"].Value = NationalitySQL;
				SqlString EthnicSQL = Ethnic;
				_dbadapter.UpdateCommand.Parameters["@Ethnic"].Value = EthnicSQL;
				SqlString ReligionSQL = Religion;
				_dbadapter.UpdateCommand.Parameters["@Religion"].Value = ReligionSQL;
				SqlString LanguageSQL = Language;
				_dbadapter.UpdateCommand.Parameters["@Language"].Value = LanguageSQL;
				SqlString InformaticSQL = Informatic;
				_dbadapter.UpdateCommand.Parameters["@Informatic"].Value = InformaticSQL;
				SqlString ProfessionalSQL = Professional;
				_dbadapter.UpdateCommand.Parameters["@Professional"].Value = ProfessionalSQL;
				SqlString EducationSQL = Education;
				_dbadapter.UpdateCommand.Parameters["@Education"].Value = EducationSQL;
				SqlString JobSQL = Job;
				_dbadapter.UpdateCommand.Parameters["@Job"].Value = JobSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.UpdateCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlDateTime IDCardDateSQL = SqlDateTime.Null;
				if (IDCardDate > DateTime.MinValue)
				{
					try
					{
						IDCardDateSQL = IDCardDate;
					}
					catch (Exception eIDCardDate)
					{
						String IDCardDateMessage = eIDCardDate.Message;
						IDCardDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@IDCardDate"].Value = IDCardDateSQL;
				SqlString IDCardPlaceSQL = IDCardPlace;
				_dbadapter.UpdateCommand.Parameters["@IDCardPlace"].Value = IDCardPlaceSQL;
				SqlString HealthSQL = Health;
				_dbadapter.UpdateCommand.Parameters["@Health"].Value = HealthSQL;
				SqlDouble HeightSQL = Height;
				_dbadapter.UpdateCommand.Parameters["@Height"].Value = HeightSQL;
				SqlDouble WeightSQL = Weight;
				_dbadapter.UpdateCommand.Parameters["@Weight"].Value = WeightSQL;
				SqlString ExperienceSQL = Experience;
				_dbadapter.UpdateCommand.Parameters["@Experience"].Value = ExperienceSQL;
				SqlDateTime InputFileDateSQL = SqlDateTime.Null;
				if (InputFileDate > DateTime.MinValue)
				{
					try
					{
						InputFileDateSQL = InputFileDate;
					}
					catch (Exception eInputFileDate)
					{
						String InputFileDateMessage = eInputFileDate.Message;
						InputFileDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@InputFileDate"].Value = InputFileDateSQL;
				SqlString Position1SQL = Position1;
				_dbadapter.UpdateCommand.Parameters["@Position1"].Value = Position1SQL;
				SqlString Position2SQL = Position2;
				_dbadapter.UpdateCommand.Parameters["@Position2"].Value = Position2SQL;
				SqlMoney ExpectSalarySQL = ExpectSalary;
				_dbadapter.UpdateCommand.Parameters["@ExpectSalary"].Value = ExpectSalarySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.UpdateCommand.Parameters["@Status"].Value = StatusSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.UpdateCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.UpdateCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.UpdateCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString PersonJobSQL = PersonJob;
				_dbadapter.UpdateCommand.Parameters["@PersonJob"].Value = PersonJobSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_CANDIDATE_Update: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_CANDIDATE_Update: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_CANDIDATE_Disable(String CandidateCode, ref Boolean Enabled)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_CANDIDATE_Disable");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@enabled", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.UpdateCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				_dbadapter.UpdateCommand.Parameters["@enabled"].Direction = ParameterDirection.Output;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_CANDIDATE_Disable: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_CANDIDATE_Disable: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_CANDIDATE_Delete(String CandidateCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.DeleteCommand = new SqlCommand("HRM_CANDIDATE_Delete");
				_dbadapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.DeleteCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.DeleteCommand.Transaction = _trans;

				_dbadapter.DeleteCommand.Parameters.Clear();
				_dbadapter.DeleteCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.DeleteCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.DeleteCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.DeleteCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_CANDIDATE_Delete: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_CANDIDATE_Delete: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.DeleteCommand != null)
					_dbadapter.DeleteCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_CANDIDATE_Save(String CandidateCode, String RecruitmentCode, String FirstName, String LastName, String Marriage, Boolean Sex, DateTime Birthday, String BirthPlace, String MainAddress, String ContactAddress, String CellPhone, String HomePhone, String Email, String Photo, String Nationality, String Ethnic, String Religion, String Language, String Informatic, String Professional, String Education, String Job, String IDCard, DateTime IDCardDate, String IDCardPlace, String Health, Double Height, Double Weight, String Experience, DateTime InputFileDate, String Position1, String Position2, Decimal ExpectSalary, Int32 Status, String PersonName, String PersonPhone, String PersonAddress, String PersonJob, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_CANDIDATE_Save");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RecruitmentCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar, 50));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Marriage", SqlDbType.NVarChar, 50));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Birthday", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@BirthPlace", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MainAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ContactAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@CellPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Photo", SqlDbType.Image));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Nationality", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Ethnic", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Religion", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Language", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Informatic", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Professional", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Education", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Job", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCard", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCardDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@IDCardPlace", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Health", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Height", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Weight", SqlDbType.Float));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Experience", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@InputFileDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Position1", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Position2", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@ExpectSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonJob", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.UpdateCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				SqlString RecruitmentCodeSQL = RecruitmentCode;
				_dbadapter.UpdateCommand.Parameters["@RecruitmentCode"].Value = RecruitmentCodeSQL;
				SqlString FirstNameSQL = FirstName;
				_dbadapter.UpdateCommand.Parameters["@FirstName"].Value = FirstNameSQL;
				SqlString LastNameSQL = LastName;
				_dbadapter.UpdateCommand.Parameters["@LastName"].Value = LastNameSQL;
				SqlString MarriageSQL = Marriage;
				_dbadapter.UpdateCommand.Parameters["@Marriage"].Value = MarriageSQL;
				SqlBoolean SexSQL = Sex;
				_dbadapter.UpdateCommand.Parameters["@Sex"].Value = SexSQL;
				SqlDateTime BirthdaySQL = SqlDateTime.Null;
				if (Birthday > DateTime.MinValue)
				{
					try
					{
						BirthdaySQL = Birthday;
					}
					catch (Exception eBirthday)
					{
						String BirthdayMessage = eBirthday.Message;
						BirthdaySQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@Birthday"].Value = BirthdaySQL;
				SqlString BirthPlaceSQL = BirthPlace;
				_dbadapter.UpdateCommand.Parameters["@BirthPlace"].Value = BirthPlaceSQL;
				SqlString MainAddressSQL = MainAddress;
				_dbadapter.UpdateCommand.Parameters["@MainAddress"].Value = MainAddressSQL;
				SqlString ContactAddressSQL = ContactAddress;
				_dbadapter.UpdateCommand.Parameters["@ContactAddress"].Value = ContactAddressSQL;
				SqlString CellPhoneSQL = CellPhone;
				_dbadapter.UpdateCommand.Parameters["@CellPhone"].Value = CellPhoneSQL;
				SqlString HomePhoneSQL = HomePhone;
				_dbadapter.UpdateCommand.Parameters["@HomePhone"].Value = HomePhoneSQL;
				SqlString EmailSQL = Email;
				_dbadapter.UpdateCommand.Parameters["@Email"].Value = EmailSQL;
				SqlBinary PhotoSQL = Convert.FromBase64String(Photo);
				_dbadapter.UpdateCommand.Parameters["@Photo"].Value = PhotoSQL;
				SqlString NationalitySQL = Nationality;
				_dbadapter.UpdateCommand.Parameters["@Nationality"].Value = NationalitySQL;
				SqlString EthnicSQL = Ethnic;
				_dbadapter.UpdateCommand.Parameters["@Ethnic"].Value = EthnicSQL;
				SqlString ReligionSQL = Religion;
				_dbadapter.UpdateCommand.Parameters["@Religion"].Value = ReligionSQL;
				SqlString LanguageSQL = Language;
				_dbadapter.UpdateCommand.Parameters["@Language"].Value = LanguageSQL;
				SqlString InformaticSQL = Informatic;
				_dbadapter.UpdateCommand.Parameters["@Informatic"].Value = InformaticSQL;
				SqlString ProfessionalSQL = Professional;
				_dbadapter.UpdateCommand.Parameters["@Professional"].Value = ProfessionalSQL;
				SqlString EducationSQL = Education;
				_dbadapter.UpdateCommand.Parameters["@Education"].Value = EducationSQL;
				SqlString JobSQL = Job;
				_dbadapter.UpdateCommand.Parameters["@Job"].Value = JobSQL;
				SqlString IDCardSQL = IDCard;
				_dbadapter.UpdateCommand.Parameters["@IDCard"].Value = IDCardSQL;
				SqlDateTime IDCardDateSQL = SqlDateTime.Null;
				if (IDCardDate > DateTime.MinValue)
				{
					try
					{
						IDCardDateSQL = IDCardDate;
					}
					catch (Exception eIDCardDate)
					{
						String IDCardDateMessage = eIDCardDate.Message;
						IDCardDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@IDCardDate"].Value = IDCardDateSQL;
				SqlString IDCardPlaceSQL = IDCardPlace;
				_dbadapter.UpdateCommand.Parameters["@IDCardPlace"].Value = IDCardPlaceSQL;
				SqlString HealthSQL = Health;
				_dbadapter.UpdateCommand.Parameters["@Health"].Value = HealthSQL;
				SqlDouble HeightSQL = Height;
				_dbadapter.UpdateCommand.Parameters["@Height"].Value = HeightSQL;
				SqlDouble WeightSQL = Weight;
				_dbadapter.UpdateCommand.Parameters["@Weight"].Value = WeightSQL;
				SqlString ExperienceSQL = Experience;
				_dbadapter.UpdateCommand.Parameters["@Experience"].Value = ExperienceSQL;
				SqlDateTime InputFileDateSQL = SqlDateTime.Null;
				if (InputFileDate > DateTime.MinValue)
				{
					try
					{
						InputFileDateSQL = InputFileDate;
					}
					catch (Exception eInputFileDate)
					{
						String InputFileDateMessage = eInputFileDate.Message;
						InputFileDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@InputFileDate"].Value = InputFileDateSQL;
				SqlString Position1SQL = Position1;
				_dbadapter.UpdateCommand.Parameters["@Position1"].Value = Position1SQL;
				SqlString Position2SQL = Position2;
				_dbadapter.UpdateCommand.Parameters["@Position2"].Value = Position2SQL;
				SqlMoney ExpectSalarySQL = ExpectSalary;
				_dbadapter.UpdateCommand.Parameters["@ExpectSalary"].Value = ExpectSalarySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.UpdateCommand.Parameters["@Status"].Value = StatusSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.UpdateCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.UpdateCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.UpdateCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString PersonJobSQL = PersonJob;
				_dbadapter.UpdateCommand.Parameters["@PersonJob"].Value = PersonJobSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_CANDIDATE_Save: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_CANDIDATE_Save: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_CANDIDATE_GetList()
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_CANDIDATE_GetList");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Prepare();
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_CANDIDATE_GetList: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_CANDIDATE_Get(String CandidateCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_CANDIDATE_Get");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@CandidateCode", SqlDbType.VarChar, 20));
				_dbadapter.SelectCommand.Prepare();
				SqlString CandidateCodeSQL = CandidateCode;
				_dbadapter.SelectCommand.Parameters["@CandidateCode"].Value = CandidateCodeSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_CANDIDATE_Get: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_CANDIDATE_GetListByRecruitmentCode(String RecruitmentCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_CANDIDATE_GetListByRecruitmentCode");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@RecruitmentCode", SqlDbType.VarChar, 20));
				_dbadapter.SelectCommand.Prepare();
				SqlString RecruitmentCodeSQL = RecruitmentCode;
				_dbadapter.SelectCommand.Parameters["@RecruitmentCode"].Value = RecruitmentCodeSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_CANDIDATE_GetListByRecruitmentCode: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
	}
}
